<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>${name_china}管理-编辑${name_china}</title>
<%@include file="/common/head.jsp" %>
<style>
.form-cont>input{
line-height:30px;
}
</style>
</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>编辑${name_china}</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="form" method="post">
    <div class="form-wrapper">    
      <input type="hidden" id="id" name="id"/> 
      <input type="hidden" id="dealState" name="dealState"/>  
      
      <div class="form-cont">
       <p class="form-cont-title">买家ID：</p>
       <input type="text" id="userId" name="userId" data-validatebox="validType:['maxLength[255]']"/> 
	   </div>
	   <div class="form-cont">
       <p class="form-cont-title">买家昵称：</p>
       <input type="text" id="userNickName" name="userNickName" data-validatebox="validType:['maxLength[255]']"/> 
	   </div>
	   <div class="form-cont">
       <p class="form-cont-title">售后编号：</p>
       <input type="text" id="id" name="id" data-validatebox="validType:['maxLength[255]']"/> 
	   </div>
	   <div class="form-cont">
       <p class="form-cont-title">商品名称：</p>
       <input type="text" id="goodsName" name="goodsName" data-validatebox="validType:['maxLength[255]']"/> 
	   </div>
	   <div class="form-cont">
       <p class="form-cont-title">申请时间：</p>
       <input type="text" id="createTime" name="createTime" data-validatebox="validType:['maxLength[255]']"/> 
	   </div>
       <div class="form-cont">
       <p class="form-cont-title">申请类型：</p>
       <input type="text" id="type" name="type" data-validatebox="validType:['maxLength[255]']"/> 
	   </div>
	   <div class="form-cont">
       <p class="form-cont-title">申请原因：</p>
       <input type="text" id="applyReason" name="applyReason" data-validatebox="validType:['maxLength[255]']"/> 
	   </div>
	   <div class="form-cont">
	   <p class="form-cont-title">申请原因说明：</p>
          <textarea class="summer-textarea" id="content" name="content"></textarea>
	   </div>
	   <div class="form-cont" id="goodsImg">
	   
	   </div>
	   
	</div>
     <div class="form-btn-wrapper" id="funcbar">
        <a class="btn btn-normal" id="agree">同意</a>
        <a class="btn btn-normal" id="refuse">拒绝</a>
        <a class="btn btn-normal" id="backBtn">关闭</a>
    </div>
</form>
<script>
    
  var   img,
  		editData,
  		permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
    	editData = ${editData};
    	$('#form').form({
			onLoadSuccess : function(data) {
			}
		}).form('loadDataEdit', {
			data : editData
		});
    	var state = $("#dealState").val();
    	//只有待处理时，操作按钮可见
    	if(state != "待处理"){
    		$("#agree").hide();
    		$("#refuse").hide();
    	}
    	img = ${img};
    	var html = null;
    	for(var i=0;i<img.length;i++){
    		if(html == null){
    			html = '<img height="100" width="100" src = "'+img[i]+'">';
    		}else{
    			html = html + '<img height="100" width="100" src = "'+img[i]+'">';
    		}
    	}
    	console.log(html);
    	$("#goodsImg").append(html);
	    //同意
		$('#agree').on('click', submitAgree);
		//拒绝
		$('#refuse').on('click', submitRefuse);
		//返回按钮
		$('#goBack').on('click', backMain);
		$("#backBtn").on('click',backMain);
	});

	//表单提交
	function submitAgree() {
		$("#form").form({
			ajax : {
				url : CONST_URL.AGREE
			},
			onSubmitSuccess : function(data) {
				$.stip({
					type : 'ok',//显示类型 有info、 ok、 danger
					text : '保存成功！',
					onBeforeHide : function() {
						backMain();
					}
				});
			}
		}).form("submit");
	}

	//表单提交
	function submitRefuse() {
		$("#form").form({
			ajax : {
				url : CONST_URL.REFUSE
			},
			onSubmitSuccess : function(data) {
				$.stip({
					type : 'ok',//显示类型 有info、 ok、 danger
					text : '保存成功！',
					onBeforeHide : function() {
						backMain();
					}
				});
			}
		}).form("submit");
	}
	//返回主页面
	function backMain() {
		window.location.href = CONST_URL.INIT_MAIN;
	}

	//请求url
	var CONST_URL = {
		INIT_MAIN : basePath + "${common_url}init",
		AGREE : basePath + "${common_url}agree",
		REFUSE : basePath + "${common_url}refuse"
	};
</script>
</body>
</html>